package com.wdfu.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @author wangdingfu
 * @Description:
 * @date 2020/5/2下午9:35
 */
@Component
@Slf4j
public class KafkaConsumerService {

    @KafkaListener(topics = "test01")
    public void kafkaListener(ConsumerRecord<String, Object> record, Acknowledgment acknowledgment, Consumer<?, ?> consumer) {
        log.info("//// kafka消费者接收消息:{}", record.value());
        //手工牵收消息
        acknowledgment.acknowledge();
    }
}
